package com.neuedu.nas.back.casback.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.neuedu.nas.back.casback.dao.UserDao;
import com.neuedu.nas.back.casback.pojo.User;
import com.neuedu.nas.back.casback.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceServiceImpl implements UserService {
    @Autowired
    UserDao userDao;
    @Override
    public boolean insert(User user) {
        int insert = userDao.insert(user);
         if (insert==1){
             return true;
         }else {
             return false;
         }
    }

    @Override
    public List<User> groupUser() {
        List<User> list = userDao.selectList(null);

        return list;
    }

    @Override
    public boolean deleteUser(Integer id) {
        int i = userDao.deleteById(id);
        return i!=0;
    }

    @Override
    public boolean updateUser(Integer id, User user) {
        UpdateWrapper updateWrapper=new UpdateWrapper();
        updateWrapper.eq("id",id);
        int update = userDao.update(user, updateWrapper);
        return update!=0;
    }
}
